package com.example.shop_2208

import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.core.app.ActivityCompat
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.mylibrary.User
import com.example.shop_2208.databinding.ActivityMainBinding
import com.example.shop_2208.entity.UserEntity
import com.example.shop_2208.mvvm.BaseViewActivity
@Route(path = "/app/main")
class MainActivity : BaseViewActivity<ActivityMainBinding>() {

   /* @Autowired
    @JvmField
    var name = "张三"
    @Autowired
    @JvmField
    var pwd = "123456"*/
    @Autowired
    lateinit var user: UserEntity

    override fun initData() {
    }

    override fun initView() {
        ARouter.getInstance().inject(this)//这行一定要存在，不然不会进行赋值操作---一定注意先后顺序，不然可能会出现空指针异常问题
        /**
         * 如果直接从欢迎页跳转到此界面，传值类型为序列化时，会报错  传值类型为字符串等时，不会报错
         */
       /* Log.d("sss", "initView: 接收到的用户名是${user.username},${user.password}")*/
        //找到frament
        val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
        //找到控制器
        val navController = navHostFragment.navController
        //进行绑定
        binding.bottom.setupWithNavController(navController)


    }

    override fun getLayout(): Int  = R.layout.activity_main
}